Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

greenlight: wait for channel reestablished #1093

Merged
merged 1 commit into from
Oct 14, 2024
Merged

Conversation

JssDWt
Copy link
Contributor

@JssDWt JssDWt commented Oct 3, 2024

The calls to send_pay are not covered by greenlight's awaitable channel futures. Therefore wait for channels to be reestablished before doing any calls to send_pay.

Alternative to Blockstream/greenlight#522

Copy link
Collaborator

@dangeross dangeross left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good

small nit, can you capitalise the error strings?

libs/sdk-core/src/greenlight/node_api.rs Outdated Show resolved Hide resolved
libs/sdk-core/src/greenlight/node_api.rs Show resolved Hide resolved
libs/sdk-core/src/greenlight/node_api.rs Outdated Show resolved Hide resolved
@JssDWt
Copy link
Contributor Author

JssDWt commented Oct 4, 2024

Capitalized error strings and use ok_or rather than a verbose match statement.

@@ -960,7 +1021,7 @@ impl NodeAPI for Greenlight {
"send_pay route to pay: {:?}, received_amount = {}",
route, to_pay_msat
);

self.wait_channel_reestablished(&max.path).await?;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As far as I know greenlight has a mechanism to wait for channel re-establishment before attempting to pay, what is the benefit of adding such mechanism on the client too?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or perhaps this mechanism doesn't exist in send_pay and that's why it is added here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or perhaps this mechanism doesn't exist in send_pay and that's why it is added here?

exactly: Blockstream/greenlight#522

@roeierez
Copy link
Member

roeierez commented Oct 8, 2024

@JssDWt I talked to Christian today and:

  1. You are right the mechanism is not there.
  2. The get_route that we execute before doesn't care about channel activeness so your analysis is correct.

The one thing he noted is that peer_connected is not enough for channel re-establishment but we need to check the channel state. I believe this is the check in greenlight: https://github.com/Blockstream/greenlight/blob/main/libs/gl-plugin/src/awaitables.rs#L177
@cdecker can you verify that?

@JssDWt
Copy link
Contributor Author

JssDWt commented Oct 8, 2024

The one thing he noted is that peer_connected is not enough for channel re-establishment but we need to check the channel state. I believe this is the check in greenlight: https://github.com/Blockstream/greenlight/blob/main/libs/gl-plugin/src/awaitables.rs#L177

I included that check in this PR: https://github.com/breez/breez-sdk-greenlight/pull/1093/files#diff-7466a53546c6cded460ef5502a9168b13cc930d94fdf7d0ea8166bb10c75fe7eR741

@roeierez
Copy link
Member

roeierez commented Oct 8, 2024

The one thing he noted is that peer_connected is not enough for channel re-establishment but we need to check the channel state. I believe this is the check in greenlight: https://github.com/Blockstream/greenlight/blob/main/libs/gl-plugin/src/awaitables.rs#L177

I included that check in this PR: https://github.com/breez/breez-sdk-greenlight/pull/1093/files#diff-7466a53546c6cded460ef5502a9168b13cc930d94fdf7d0ea8166bb10c75fe7eR741

Oh perfect. How did I miss that?

Copy link
Member

@roeierez roeierez left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

The calls to `send_pay` are not covered by greenlight's awaitable channel futures. Therefore wait for channels to be reestablished before doing any calls to `send_pay`.
@JssDWt JssDWt merged commit c8c0ae1 into main Oct 14, 2024
9 checks passed
@JssDWt JssDWt deleted the jssdwt-awaitable-channels branch October 14, 2024 10:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants